Skip to content

Scroll to the user's own comment in expense reports when the new-message indicator is showing - #103174

Merged
NicolasBonet merged 8 commits into
mainfrom
claude-scrollExpenseReportOnOwnComment
Oct 15, 2026
Merged

NicolasBonet merged 8 commits into
mainfrom
claude-scrollExpenseReportOnOwnComment

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

When you send a comment while scrolled up in an expense report with the new-message indicator showing, the list now scrolls down to your comment.

  • useReportActionsNewActionLiveTail: when an unread marker is present but the newest actions are already loaded, scroll directly to the bottom instead of triggering a redundant openReport round trip. Also removes an unreachable dead-code branch.
  • ReportActionsList: flush a pending scroll-to-bottom from onContentSizeChange, which fires after FlashList measures the new row. In aligned-to-top reports (expense, invoice, transaction thread), onLayout alone does not fire on new content.

AI tests run by MelvinBot: affected unit tests, typecheck, lint, and React Compiler check pass.

Fixed Issues

$ #103157
PROPOSAL: #103157 (comment)

Tests

Precondition: User A and User B are both members of an IOU expense report that has enough comments to scroll.

  1. As User A, open the IOU expense report and scroll to the top.
  2. As User B, add a comment to the same expense report.
  3. As User A, verify the new-message indicator appears.
  4. As User A, add and send a comment.
  5. Verify the list scrolls to the comment and the indicator hides.
  • Verify that no errors appear in the JS console

Offline tests

  1. As User A, open an IOU expense report with one expense and enough comments to scroll, and scroll to the top.
  2. Go offline.
  3. Send a comment.
  4. Verify the list scrolls to the bottom and your pending comment is visible.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Screenshots and videos will be added in the reviewer checklist.

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…omment

Co-authored-by: Abdelrahman Khattab <abzokhattab@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team October 6, 2026 12:13
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Oct 6, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch because I don't have push access to your fork.

To take ownership of this branch and push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-scrollExpenseReportOnOwnComment
git checkout -b claude-scrollExpenseReportOnOwnComment upstream/claude-scrollExpenseReportOnOwnComment
git push -u origin claude-scrollExpenseReportOnOwnComment

Then you can close this PR and open a new one from your fork.

@MelvinBot

MelvinBot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

I set up an expense report with 20 comments, but I couldn't scroll its comment list to the top on Web, so I couldn't test the fix itself. The test tool's web scroll found no scrollable content in this list, and drag, pan, and swipe aren't supported on web. I didn't see an app defect.

Final report state with comments 5-20 visible

Step Status
Setup: User A signed in, expense report created with enough comments to scrollFinished onboarding, created "Expense Report 2026-10-06", and added 20 comments. Only the last 10 or so fit on screen.
Expense report fixture with comments overflowing the viewport
✅
1. As User A, scroll the comment list to the topBlocked by the test tool, not the app. The tool has no Home or PageUp key press on web. Scroll commands of 300-3000px, tried at three viewport heights, didn't move the list. Drag, pan, and swipe returned "not supported on web". Comment 1 never came into view.
Comments 5-20 visible; comments 1-4 out of view and unreachable by scroll
❌
2. As User B, add a comment to the same reportNot run. The web test setup supports only one signed-in user.
⚠️
3. While User A is at the top, the new-message indicator appearsNot run. This step needs step 2.
⚠️
4-6. User A sends a comment from the top; the list scrolls to the new comment and the indicator hidesCouldn't test because step 1 was blocked. Sending from the bottom of the list wouldn't test the fix, so I didn't count that as a pass.
❌
7. Regression: from the top with no indicator, send a comment; the list scrolls to the bottomCouldn't test because step 1 was blocked.
❌
8. No errors appear in the JS consoleNo error banners or crash dialogs appeared. Every AddComment, GetMissingOnyxMessages, and Ping request returned 200. The tool can't read the browser console on web, so this check covers only the screen and network requests.
✅

view run · view recording

@MelvinBot

MelvinBot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ❌ fail

The Android run never reached the PR's code. The app froze while I was adding the first expense to a new workspace expense report, and one Metro restart didn't recover it. The failures below are from that freeze, not evidence that the fix doesn't work.

App frozen on the Add expense sheet after the Metro restart

Step Status
1. As User A, scroll the comment list to the top (first comment visible) in a workspace expense reportNot reached. I created "Expense Report 2026-10-06" in a new workspace and confirmed it opens in the expense report view. The app froze on Add expense > Create expense before I could add any comments.
Draft expense report in the new workspace with the Add expense menu open
❌
2. As User B, add a comment to the same expense reportNot run. The test setup supports only one signed-in user.
⚠️
3. While User A is at the top, the new-message indicator appearsNot run. This step needs step 2.
⚠️
4. As User A, type and send a comment while scrolled to the topNot reached because of the app freeze.
❌
5. After sending, the list scrolls to the bottom and shows the new commentNot reached because of the app freeze.
❌
6. After sending, the new-message indicator is hiddenNot run. No indicator was ever shown because steps 2-3 weren't run.
⚠️
7. Regression: scroll to the top again, send another comment; the list scrolls to the bottomNot reached because of the app freeze.
❌
8. No errors or crashes appearNo red box or crash appeared. The app stopped responding to taps and the back button after the Add expense sheet opened, and JS logging stopped. It stayed frozen after one Metro restart.
App frozen on the Add expense sheet after the Metro restart
❌
Extra: self-DM chat (not the PR's code path)Before the rerun, I tested in the self DM by mistake. That chat uses the normal chat list, not the expense report view this PR changes. After I scrolled to the top and sent a comment, the list stayed at the top both times. Don't use this result to judge the PR.
Self-DM: scrolled to top before first sendSelf-DM: still at top after first sendSelf-DM: scrolled to top before second sendSelf-DM: still at top after second send
❌

view run · view recording

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot This PR fixes useMoneyRequestReportScroll.ts, but that hook is only used by MoneyRequestReportActionsList, which mounts for multi-transaction reports. The bug in the issue happens on a single-transaction IOU report, which renders ReportActionsList instead (see MoneyRequestReportView.tsx:260-268 — when shouldDisplayMoneyRequestActionsList is false). So this fix cannot affect the reported scenario.

The actual code path for single-transaction reports goes through useReportActionsNewActionLiveTail.ts. Please rework the fix to target that file. Here's what needs to change:

1. Fix shouldJumpToLiveTail in useReportActionsNewActionLiveTail.ts (line 114-115):

The condition (hasNewerActions || !!linkedReportActionID || unreadMarkerReportActionID) treats a bare unreadMarkerReportActionID as a reason to call openReport, even when hasNewestReportAction is already true (the newest actions are loaded, just off-screen). This causes an unnecessary network round trip instead of a direct scrollToBottom(). Change the third disjunct to (!!unreadMarkerReportActionID && !hasNewestReportAction).

2. Fix flushPendingScrollToBottom in useReportActionsScroll.ts (line 406-413):

After the live-tail jump sets isScrollToBottomEnabled = true, the only call site for flushPendingScrollToBottom is the FlashList onLayout handler in ReportActionsList.tsx:571-574. But a new comment changes content size, not layout size, so onLayout never fires and the scroll is never flushed. Add an effect keyed on isScrollToBottomEnabled that calls flushPendingScrollToBottom (inside requestAnimationFrame to avoid synchronous state chaining).

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot make the Explanation of Change concise

Revert the useMoneyRequestReportScroll change, which only runs for multi-expense reports.
For single-expense reports, scroll straight to the bottom when the unread marker is set but the newest actions are already loaded, and flush a pending scroll-to-bottom on the next frame instead of waiting for a list layout event.

Co-authored-by: Abdelrahman Khattab <abzokhattab@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I reworked the fix to target the single-expense path in 5dce362. Both changes are in, and I reverted the earlier useMoneyRequestReportScroll change.

  1. useReportActionsNewActionLiveTail.ts:114-119: the third disjunct is now (!!unreadMarkerReportActionID && !hasNewestReportAction). When the newest actions are loaded, the hook calls scrollToBottom() directly.
  2. useReportActionsScroll.ts:415-425: a new effect keyed on isScrollToBottomEnabled calls flushPendingScrollToBottom inside requestAnimationFrame. The cleanup cancels the frame if onLayout flushes first.

I added 3 unit tests, and 2 of them fail without the fix. Typecheck, lint, the React Compiler check, and the affected test suites pass. I didn't run the full test suite or test manually on web.

I also updated the PR description, and it's shorter now.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I shortened the Explanation of Change to one sentence, two bullets (one per changed hook), and a one-line AI tests summary. I also removed the note about reverting useMoneyRequestReportScroll, because that file is no longer in the PR diff.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Yes. The "New messages" pill should hide, because the issue's expected result is "the list scrolls to comment and the indicator hides." The "New" divider line above B's comment is different: it stays for the session by design, the same as in regular chats.

I think this PR caused the pill to come back. The live-tail hook now hides the pill (useReportActionsNewActionLiveTail.ts:151) before your optimistic comment renders. When the comment renders, B's unread index shifts by 1. That shift makes an effect replay the old scrolled-up viewable items (useReportUnreadMessageScrollTracking.ts:179-185). From those stale items, B's comment looks off-screen, so the pill turns back on (line 149).

Suggested fix: when the hook scrolls to the bottom itself, clear ref.current.previousViewableItems as it hides the pill. The replay then waits for FlashList to report the real bottom items.

I haven't confirmed this at runtime. From the code, FlashList's next viewability report should hide the pill again about 250 ms later, so I'd expect a flicker rather than a pill that stays. A log in onViewableItemsChanged would show which call sets the pill last.

Why main hid the pill, and why the divider stays
  • Main: any unread marker took the openReport path. The pill was hidden only after openReport returned (useReportActionsNewActionLiveTail.ts:209), well after the index shift, so the hide stuck. The scroll never ran, which matches the issue's actual result.
  • Divider: useUnreadMarker keeps unreadMarkerTime in local state. It resets only when readNewestAction runs with shouldResetUnreadMarker (Report/index.ts:3200), and useMarkAsRead never passes that flag. Every report that uses ReportActionsList shares this code.

Reply with @MelvinBot implement the pill fix to have me push it, or tell me if you meant the divider line.

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot

The live-tail hook (useReportActionsNewActionLiveTail) was missing a markNewestActionAsRead() call when the user sends their own comment. This caused two issues after scrolling:

  1. The "New" divider stayed visible because unreadMarkerTime was never advanced
  2. The "New messages" pill reappeared because onViewableItemsChanged in useReportUnreadMessageScrollTracking saw the unread marker still existed and turned the pill back on

The money-request hook (useMoneyRequestReportScroll) already calls markNewestActionAsRead() in the same scenario — this was just missing from the chat-list path.

Changes needed:

  • Thread markNewestActionAsRead from useReportActionsScroll into useReportActionsNewActionLiveTail
  • Call it after scrollToBottom() in the direct-scroll path (own comment with newest actions loaded)
  • Call it after setIsFloatingMessageCounterVisible(false) in the await_scroll live-tail path (own comment after openReport fetches newest actions)
  • Wrap it in a useEffectEvent (markAsReadAfterScroll) so it stays out of the effect dependency arrays

Tests should also be added to verify markNewestActionAsRead is called when the user sends their own comment.

Without this, the New divider stayed visible and the unread marker turned the New messages pill back on after the scroll.

Co-authored-by: Abdelrahman Khattab <abzokhattab@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I added the markNewestActionAsRead() calls in 654e67a.

I tested both paths. The direct-scroll test now checks the call. A new test checks that nothing is marked as read while openReport loads, and that the call happens once after the newest actions arrive. Both fail without the fix.

The affected test suites, typecheck, lint, the React Compiler check, and spelling pass. I didn't run the full test suite or test manually on web. I also updated the PR description.

@abzokhattab

Copy link
Copy Markdown
Contributor

@codex @MelvinBot review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T14:34:18.115028Z 654e67a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 654e67a284

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

} else {
setIsFloatingMessageCounterVisible(false);
reportScrollManager.scrollToBottom();
markAsReadAfterScroll();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid marking unloaded actions read while offline

When the user is offline, shouldJumpToLiveTail is false even if hasNewerActions is true or the newest action is not loaded, so sending an action reaches this call and readNewestAction() advances lastReadTime to the current time. Once the queued request syncs, unseen newer messages are treated as read; defer marking until the newest actions are loaded, matching the existing hasNewerActions guard in useMarkAsRead.

Useful? React with 👍 / 👎.


liveTailJumpRef.current = {stage: 'await_prune'};
setIsFloatingMessageCounterVisible(false);
markAsReadAfterScroll();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recheck report focus before marking the live tail read

On web, previous report screens can remain mounted after navigation, so if a user starts this openReport live-tail jump and switches reports before loading finishes, this effect still runs and marks the old report read even though its newly loaded messages were never viewed. Recheck that this report is still the topmost/focused report before calling markAsReadAfterScroll().

Useful? React with 👍 / 👎.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Review

The new markNewestActionAsRead() calls don't clear the "New" divider or stop the pill from coming back. They also add a ReadNewestAction API write each time you send a comment in any chat.

1. markAsReadAfterScroll doesn't reset the unread marker (useReportActionsNewActionLiveTail.ts:98-102)

2. Extra network write for every sent comment (useReportActionsNewActionLiveTail.ts:158-162)

This branch runs for every comment the current user sends while not jumping to the live tail. That includes when they're already at the bottom with nothing unread. ReportActionsList covers all chats, so each sent message now also queues a ReadNewestAction request.

Suggested fix: Remove both markAsReadAfterScroll() calls and the new param. If the divider must clear when you send a comment, emit the reset only when unreadMarkerReportActionID is set. For example, call readNewestAction(reportID, true, true) behind that check.

Minor: The new requestAnimationFrame flush in useReportActionsScroll.ts:420-426 repeats the scrollToBottom() call that line 160 of the live-tail hook already made. On the live-tail path, it now scrolls and prunes before onLayout fires for the new window. Please confirm a long jump through openReport still ends at the bottom.

I reviewed the code only. I didn't run the app.


view run

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot simplify Explanation of Change and make test steps same as in the issue #103157 ,,, then mark the PR as ready

@MelvinBot
MelvinBot marked this pull request as ready for review October 13, 2026 14:26
@MelvinBot
MelvinBot requested a review from a team as a code owner October 13, 2026 14:27
@melvin-bot
melvin-bot Bot requested review from abzokhattab and removed request for a team October 13, 2026 14:27
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I updated the PR description and marked the PR as ready for review.

  • Explanation of Change: It's now one sentence plus the AI tests line. I removed the claim that marking as read clears the "New" divider.
  • Tests: These now match the issue's precondition and steps. The last step is the issue's expected result: "the list scrolls to the comment and the indicator hides." The Offline tests and QA Steps are unchanged.

My earlier review finding is still open. The markNewestActionAsRead() calls don't reset the unread marker, and they send an extra ReadNewestAction request for every sent comment.


view run

@melvin-bot

melvin-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

@abzokhattab Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested a review from trjExpensify October 13, 2026 14:27
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I reverted the markNewestActionAsRead changes in 9c7b785 and 030fc18, and updated the Explanation of Change.

The reverts remove:

  • The markNewestActionAsRead param from UseReportActionsNewActionLiveTailParams and from the call in useReportActionsScroll.ts.
  • The markAsReadAfterScroll and markAsReadAfterLiveTailJump effect events and both call sites.
  • The four tests that only checked the mock was called, plus the mock entries added for them.

These changes stay: the shouldJumpToLiveTail condition, the unreachable-branch removal, and the next-frame flush for shouldBeAlignedToTop. useReportActionsScroll.ts still passes markNewestActionAsRead to its own pill-click handler, as it does on main.

AI tests: the two affected test files (46 tests), typecheck, lint, and the React Compiler check pass. I didn't run the formatter here. The reverts only delete lines, so the files match the already-formatted state of 2a215e8.


view run

Comment thread src/hooks/useReportActionsScroll.ts Resolved
Comment thread src/hooks/useReportActionsScroll.ts Resolved

@trjExpensify trjExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title of this PR is a bit weird. It makes it sound like we pin an expense report preview in a chat to the latest comment or something. Can we update it to be more reflective of what the PR is changing?

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot Address Nicolas's review by replacing the useEffect + requestAnimationFrame flush with a call inside the existing onContentSizeChange handler. This is more reliable because onContentSizeChange fires after FlashList has actually measured the new content, and the isScrollToBottomEnabled guard already makes the call safe to run on every content size change.

Specifically:

  1. Remove the useEffect block at useReportActionsScroll.ts:421-427 and the flushPendingScrollToBottomFromEffect line at 415. These are the lines added by this PR.

  2. In ReportActionsList.tsx, update the existing onContentSizeChange handler (line ~588) to also call flushPendingScrollToBottom():

onContentSizeChange={() => {
    trackVerticalScrolling(undefined);
    flushPendingScrollToBottom();
}}

This way the flush happens when the list content actually changes size (i.e. after FlashList lays out the new row), not on a timing guess via rAF. The guard if (!isScrollToBottomEnabled) return inside flushPendingScrollToBottom ensures it only does work when a scroll is actually pending, so calling it on every content size change is safe.

…of on the next frame

Co-authored-by: Abdelrahman Khattab <abzokhattab@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I replaced the useEffect + requestAnimationFrame flush with a flushPendingScrollToBottom() call in onContentSizeChange, as you asked. The commit is 2403f67.

  • useReportActionsScroll.ts: removed the effect and flushPendingScrollToBottomFromEffect.
  • ReportActionsList.tsx:531-534: onContentSizeChange now calls flushPendingScrollToBottom() after trackVerticalScrolling(undefined).
  • Tests: removed the two unit tests for the effect. Added a ReportActionsListTest case that checks onContentSizeChange flushes the pending scroll.

The affected Jest suites, typecheck, lint, and React Compiler check pass. I couldn't run the oxfmt format check here. I also updated the PR description to match.

@abzokhattab

Copy link
Copy Markdown
Contributor

@MelvinBot Please update the PR title and description per trjExpensify's feedback:

New title: Scroll to the user's own comment in expense reports when the new-message indicator is showing

New Explanation of Change (replace the current one):

When you send a comment while scrolled up in an expense report with the new-message indicator showing, the list now scrolls down to your comment.

  • useReportActionsNewActionLiveTail: when an unread marker is present but the newest actions are already loaded, scroll directly to the bottom instead of triggering a redundant openReport round trip. Also removes an unreachable dead-code branch.
  • ReportActionsList: flush a pending scroll-to-bottom from onContentSizeChange, which fires after FlashList measures the new row. In aligned-to-top reports (expense, invoice, transaction thread), onLayout alone does not fire on new content.

@abzokhattab

Copy link
Copy Markdown
Contributor

Thanks @NicolasBonet @trjExpensify covered all comments

@MelvinBot MelvinBot changed the title Keep the expense report pinned to the bottom after the user sends a comment Scroll to the user's own comment in expense reports when the new-message indicator is showing Oct 14, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I updated the PR title and the Explanation of Change to match your text. I kept the existing "AI tests run by MelvinBot" line below the explanation. The rest of the description is unchanged.

@NicolasBonet
NicolasBonet merged commit d2eef46 into main Oct 15, 2026
44 of 45 checks passed
@NicolasBonet
NicolasBonet deleted the claude-scrollExpenseReportOnOwnComment branch October 15, 2026 15:45
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 NicolasBonet has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.5.10-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update is needed. This bug fix makes an expense report scroll to the comment you just sent, which is what users already expect, and no article under docs/articles describes this scroll behavior.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.5.12-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update is needed. This is a bug fix: the expense report now scrolls to the comment you just sent, which is what users already expect, and no article under docs/articles says otherwise.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.12-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants